@echo off
setlocal enabledelayedexpansion

set buildType=%~1

set cangjieTarget=aarch64-linux-android31
set cangjieFeatures=feature.env.android
set ANDROID_CJ_FRONTEND=!CJMP_SDK_HOME!\cjmp-ui\android
set ANDROID_NDK_DIR=!ANDROID_SDK_ROOT!\ndk\26.3.11579264
set SYSTEM_STRING=windows-x86_64
set ANDROID_CANGJIE_PATH=!CJMP_SDK_HOME!\cjmp-tools\third_party\cangjie-android
set ANDROID_PACKAGE=..\..\..\..\..\package\target\aarch64-linux-android31\!buildType!\pkgnative_windows

if /i !buildType!==debug (
    set cangjieExtraArgs=-g
) else (
    set cangjieExtraArgs=
)

call !CJMP_SDK_HOME!\cjmp-tools\third_party\cangjie-android\envsetup.bat || exit /b !errorlevel!
cjpm build --no-feature-deduce --enable-features=!cangjieFeatures! --target=!cangjieTarget! !cangjieExtraArgs! || exit /b !errorlevel!
if not exist "..\..\..\libs\arm64-v8a" (
    mkdir "..\..\..\libs\arm64-v8a" || exit /b !errorlevel!
)
copy ".\target\!cangjieTarget!\!buildType!\javacallcj\libjavacallcj.so" "..\..\..\libs\arm64-v8a" || exit /b !errorlevel!
